package com.wk.kxexamadminister.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wk.kxexamadminister.entity.Student;
import com.wk.kxexamadminister.entity.Teacher;
import com.wk.kxexamadminister.mapper.StudentMapper;
import com.wk.kxexamadminister.mapper.TeacherMapper;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@Api(description = "登陆 ")
public class LoginController {

    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    private TeacherMapper teacherMapper;

//    @GetMapping("/lo")
//    @ResponseBody
//    public String login(Integer user, String pwd, String job){
//        if("student".equals(job)){
//            Student student = studentMapper.selectOne(new QueryWrapper<Student>()
//                    .eq("s_num", user)
//                    .eq("pwd", pwd));
//            if(student != null){
//                return "Success";
//            }
//        }
//        if("teacher".equals(job)){
//            Teacher teacher = teacherMapper.selectOne(new QueryWrapper<Teacher>()
//                    .eq("t_id", user)
//                    .eq("pwd", pwd));
//            if(teacher != null){
//                return "Success";
//            }
//        }
//        return "查无此人";
//    }


    @GetMapping("/lo")
    @ResponseBody
    public String login(Integer user, String pwd){

            Student student = studentMapper.selectOne(new QueryWrapper<Student>()
                    .eq("s_num", user)
                    .eq("pwd", pwd));
            if(student != null){
                return "Success";
            }

        return "查无此人";
    }

}
